<template>
	<div id="account">
		<div id="header">
			<img @click="$router.go(-1)" src="../../static/img/return.png"/>
			<p>账号安全</p>
		</div>
		<router-link to="/user/phone" class="account_item">
			<div class="account_left">
				<img src="../../static/img/account-01.png"/>
				<p>修改手机号</p>
			</div>
			<div class="account_right">
				<p>{{phone}}</p>
				<img src="../../static/img/account-08.png"/>
			</div>
		</router-link>
		<router-link v-for="item in accountList" :to="item.path" class="account_item">
			<div class="account_left">
				<img :src="item.Icon"/>
				<p>{{item.title}}</p>
			</div>
			<div class="account_right">
				<img src="../../static/img/account-08.png"/>
			</div>
		</router-link>
		<input @click="logout" id="logout" type="button" value="退出登录" />
	</div>
</template>

<script>
export default{
	name: 'account',
	data:function(){
		return{
			phone: '',//手机号码
			alipay: '',	// 支付宝账号
			accountList:[
				{
					path: '/user/bankcard',
					title: '绑定银行卡',
					Icon: './static/img/account-10.png',
				},
				{
					path: '/user/accountTB',
					title: '绑定淘宝账号',
					Icon: './static/img/account-03.png',
				},
				{
					path: '/user/accountJD',
					title: '绑定京东账号',
					Icon: './static/img/account-04.png',
				},
				{
					path: '/user/accountQQ',
					title: '绑定QQ账号',
					Icon: './static/img/account-11.png',
				},
				{
					path: {path:"/user/password",query:{type:1}},
					title: '修改登录密码',
					Icon: './static/img/account-05.png',
				},
				{
					path: {path:"/user/password",query:{type:2}},
					title: '修改支付密码',
					Icon: './static/img/account-06.png',
				},
				{
					path: '/user/findPayPw',
					title: '找回支付密码',
					Icon: './static/img/account-07.png',
				},
			]
		}
	},
	methods:{
		logout:function(){
			var _this = this;
			this.$confirm("您确定要退出吗？", function(){
				localStorage.removeItem('usertoken');
				sessionStorage.removeItem('newuser');
				_this.$router.push('/');
			});
		},
		// 获取原手机号
		getUserInfo: function(){
			var _this = this;
			_this.$axios.post("/user/info/getBaseInfo").then(function(res){
				var data = res.data;
				if(data.message == "succ"){
					_this.phone = data.result.phone;
					_this.alipay = data.result.alipayAccount;
				}
			}).catch(function(err){
				console.log(err);
			});
		},
	},
	created: function(){
		this.getUserInfo();
	}
}
</script>

<style scoped>
/* ========== */
/* = Header = */
/* ========== */
#header{
	width: 100%;
	background-color: #fff;
	position: fixed;
	top: 0;
	left: 0;
	height: 4rem;
	display: flex;
	align-items: center;
	justify-content: center;
	border-bottom: 1px solid #EEEEEE;
	font-size: 1.6rem;
	color: #4F4F4F;
	box-sizing: border-box;
	z-index: 10;
}
#header img{
	height: 2rem;
	display: block;
	position: absolute;
	top: 1rem;
	left: 2rem;
}
#account{
	height: 100%;
	padding-top: 5rem;
	box-sizing: border-box;
}

.account_item{
	height: 3.6rem;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0 1.5rem;
	background-color: #fff;
	border-bottom: 1px solid #EEEEEE;
	box-sizing: border-box;
	color: #4F4F4F;
	font-size: 1.2rem;
}
.account_left{
	display: flex;
	align-items: center;
}
.account_left img{
	height: 1.4rem;
	display: block;
	margin-right: 1.5rem;
}
.account_left p{
	white-space: nowrap;
}
.account_right{
	display: flex;
	align-items: center;
}
.account_right img{
	height: 1.2rem;
	display: block;
	margin-left: 1.5rem;
}
#logout{
	width: 80%;
	max-width: 24rem;
	height: 3.6rem;
	background-color: #FF6565;
	color: #FFFFFF;
	display: block;
	margin: 0 auto;
	margin-top: 2rem;
	border: none;
	font-size: 1.4rem;
}
</style>
